package com.itkaien.service.impl;

import com.itkaien.service.SmsService;
import org.springframework.stereotype.Service;

@Service
public class AliyunSmsService implements SmsService {
    @Override
    public void sendSmsToAdmin(String message) {

    }

//    private final AliyunSmsConfig config;
//
//    public AliyunSmsService(AliyunSmsConfig config) {
//        this.config = config;
//    }
//
//    @Override
//    public void sendSmsToAdmin(String message) {
//        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", config.getAccessKeyId(), config.getAccessKeySecret());
//        IAcsClient client = new DefaultAcsClient(profile);
//        // 创建短信请求对象
//        SendSmsRequest request = new SendSmsRequest();
//        request.setPhoneNumbers(config.getAdminPhoneNumber());
//        request.setSignName(config.getSignName());
//        request.setTemplateCode(config.getTemplateCode());
//        request.setTemplateParam("{\"message\":\"" + message + "\"}");
//        // 发送短信
//        try {
//            SendSmsResponse response = client.getAcsResponse(request);
//            if ("OK".equals(response.getCode())) {
//                System.out.println("短信发送成功，短信ID：" + response.getBizId());
//            } else {
//                System.out.println("短信发送失败，原因：" + response.getMessage());
//            }
//        } catch (Exception e) {
//            System.out.println("短信发送异常：" + e.getMessage());
//        }

}